package com.itheima.mapper;


import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckitemMapper {
    /**
     * 新增检查项
     * @param checkItem
     * @return
     */
    @Insert("insert into t_checkitem (code, name, sex, age, price, type, attention, remark) " +
            "VALUES" +
            "(#{code},#{name},#{sex},#{age},#{price},#{type},#{attention},#{remark})")
    void addItem(CheckItem checkItem);
    /**
     * 根据id删除检查项
     */
    @Delete("delete from t_checkitem where id = #{id}")
    void deleteItem(Integer id);
    /**
     * 根据检查组id查询关联的检查项id
     */
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    Integer[] findCheckItemIdsByCheckGroupId(Integer id);
    /**
     * 编辑检查项
     */
    void editItem(CheckItem checkItem);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*) from t_checkitem")
    Long countAll();

    /**
     * 分页查询_查询返回当前页的list
     * @return
     */
    @Select("select * from t_checkitem")
    List<CheckItem> findPage();
    /**
     * 根据id查询检查项
     */
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);

    /**
     * 根据code查询对应的id
     * @param checkitemCodes
     * @return
     */
    List<Integer> findByCode(List<String> checkitemCodes);
}
